#include<iostream>
using namespace std;

//静态变量只有一个副本，不管有多少对象
//静态成员函数没有this指针，只能访问静态成员变量

class Box
{
private:
    double length, width, height;
public:
    static int objectCount;
    Box(double l = 2.0, double b = 2.0, double h = 2.0) {
        cout << "constructor called " << endl;
        length = l;
        width = b;
        height = h;
        objectCount++;
    }

    double Volumne(){
        return length * width * height;
    }
};

//只能在类外部初始化静态变量
int Box::objectCount = 0;

int main(void){
    Box Box1(3.3, 1.2, 1.5);
    cout << "total object : " << Box::objectCount << endl;
    Box Box2(3.3, 3.3, 3.3);
    cout << "total object : " << Box::objectCount << endl;
}